package com.example.yf.result;

public enum ResultCodeEnum {
    SUCCESS(200,"操作成功"),
    ERROR(201,"操作失败"),
    SEARCH_ERROR(202,"后台异常了先生"),

    ;

    private int code;
    private String msg;

    ResultCodeEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public int getCode(){
        return code;
    }
    public String getMsg(){
        return msg;
    }

    public static ResultCodeEnum find(int code) {
        for (ResultCodeEnum resultCodeEnum : ResultCodeEnum.values()){
            if (resultCodeEnum.getCode()==code){
                return resultCodeEnum;
            }
        }
        return null;
    }

    public static void main(String[] arge){
        System.out.println(find(200).getMsg());
    }

}
